package com.eternal.log.adapter;

import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import android.util.SparseArray;
import android.view.ViewGroup;
import android.widget.TextView;

import com.eternal.base.database.entity.Log;
import com.eternal.log.R;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * Created by Administrator
 * On 2020/5/14
 * Description:
 * @author Administrator
 */
public class LogHeaderHolder extends LogHolder {
    private TextView month;

    public LogHeaderHolder(@NonNull ViewGroup parent, @LayoutRes int layout){
        super(parent, layout);
        month=itemView.findViewById(R.id.tv_month);
    }

    public LogHeaderHolder(@NonNull ViewGroup parent) {
        this(parent, R.layout.log_item_header);
    }

    @Override
    public Date init(Log log, long start, SparseArray<String> cache, boolean isDegree) {
        Date result=super.init(log, start,cache, isDegree);
        SimpleDateFormat format=new SimpleDateFormat("yyyy MMM dd", Locale.ENGLISH);
        month.setText(format.format(result).toUpperCase());
        return result;
    }
}
